exports.__esModule = true;

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }

exports.default = class extends think.BaseController {
  /**
     * @description 获取标识信息
     */
  getOperationAction() {
    var _this = this;

    return _asyncToGenerator(function* () {
      const OperationService = _this.service('sys/OperationService');
      const getData = _this.get('page,pageSize,name,code');
      const res = yield OperationService.getOperation(getData);
      if (res && res.error) {
        return _this.errorJson('查询失败');
      } else {
        return _this.successJson(res);
      }
    })();
  }
  /**
   * @description 获取所有权限标识
   */
  saveOperationAction() {
    var _this2 = this;

    return _asyncToGenerator(function* () {
      const OperationService = _this2.service('sys/OperationService');
      const postData = _this2.post('id,name,code,color,icon');
      const res = yield OperationService.upDataOperation(postData);
      if (res && res.error) {
        return _this2.errorJson(res.error);
      } else {
        return _this2.successJson(res);
      }
    })();
  }

  /**
   * @description 删除权限标识
   */
  delOperationAction() {
    var _this3 = this;

    return _asyncToGenerator(function* () {
      const OperationService = _this3.service('sys/OperationService');
      const PostData = {
        id: _this3.post('id')
      };
      const res = yield OperationService.delOperation(PostData);
      if (res && res.error) {
        return _this3.errorJson(res.error);
      } else {
        return _this3.successJson(res);
      }
    })();
  }

  /**
   * @description 获取所有权限标识
   */
  getOperationAllAction() {
    var _this4 = this;

    return _asyncToGenerator(function* () {
      const OperationService = _this4.service('sys/OperationService');
      const res = yield OperationService.getOperationAll();
      if (res && res.error) {
        return _this4.errorJson('查询失败');
      } else {
        return _this4.successJson(res);
      }
    })();
  }
};